package com.gcl.kgsvc.controller;

import com.gcl.kgsvc.service.RestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/rest")
public class TestController {

    @Autowired
    private RestService restSvc;

    @GetMapping("/get")
    @ResponseBody
    public Map<String, Object> getTest(@RequestParam("id") String id) {
        // 可以直接请求此地址  http://localhost:8080/rest/get?id=123
        return restSvc.getService(id);
    }

    @PostMapping("post")
    @ResponseBody
    public Map<String, Object> postTest(@RequestBody() Map<String, Object> data) {
        // 通过Postan、API fox等测试工具，以POST方式请求  localhost:8080/rest/post
        // 参数可以设置为  {"content":"the request body"}  格式为JSON
        return restSvc.postService(data);
    }
}
